var xiaoshuo = new Vue({
	el: '#novel',
	data: {
		list: [{
			id: 'fantasy',
			title: '玄幻奇幻',
			icon: 'https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/img/moe/1102mt1.jpg',
			introduce: '(＾Ｕ＾)ノyo~',
			go: "/novel/list/?type=fantasy"
		},{
			id: 'coatard',
			title: '武侠仙侠',
			icon: 'https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/img/moe/1102mt1.jpg',
			introduce: 'ヾ(。￣□￣)ﾂ゜゜゜',
			go: "/novel/list/?type=coatard"
		},{
			id: 'urban',
			title: '都市言情',
			icon: 'https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/img/moe/1102mt1.jpg',
			introduce: '(〃｀ 3′〃)',
			go: "/novel/list/?type=urban"
		},{
			id: 'history',
			title: '历史军事',
			icon: 'https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/img/moe/1102mt1.jpg',
			introduce: '(⊙_⊙)?',
			go: "/novel/list/?type=history"
		},{
			id: 'science',
			title: '科幻灵异',
			icon: 'https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/img/moe/1102mt1.jpg',
			introduce: '(*^▽^*)',
			go: "/novel/list/?type=science"
		},{
			id: 'webgame',
			title: '网游竞技',
			icon: 'https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/img/moe/1102mt1.jpg',
			introduce: '(。・・)ノ',
			go: "/novel/list/?type=webgame"
		},{
			id: 'girl',
			title: '女频频道',
			icon: 'https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/img/moe/1102mt1.jpg',
			introduce: '(〝▼皿▼）',
			go: "/novel/list/?type=girl"
		},
		// 	{
		// 	id: 'complete',
		// 	title: '全本小说',
		// 	icon: 'https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/img/moe/1102mt1.jpg',
		// 	introduce: '(￣︶￣)↗',
		// 	go: "/novel/list/?type=complete"
		// }
		],
		localData: {  //使用pass表示该数据为空，所有书对象里都是数组类型，存放最近的三个对象
			latelyType: [{
				id: '',
				title: '',
				icon: '',
				introduce: '',
				go: ""
			}, {
				id: '',
				title: '',
				icon: '',
				introduce: '',
				go: ""
			},{
				id: '',
				title: '',
				icon: '',
				introduce: '',
				go: ""
			},{
				id: '',
				title: '',
				icon: '',
				introduce: '',
				go: ""
			}], //最近浏览的小说类别
			latelyList: [{ // 最近看过的小说
				title: '', // 书名
				href: '',  // 链接
				latelyCatalogue: [{ // 最近看的章节
					chapter: '', // 章节名
					href: ''  // 链接
				},{
					chapter: '', // 章节名
					href: ''  // 链接
				},{
					chapter: '', // 章节名
					href: ''  // 链接
				}]
			},{
				title: '', // 书名
				href: '',  // 链接
				latelyCatalogue: [{ // 最近看的章节
					chapter: '', // 章节名
					href: ''  // 链接
				},{
					chapter: '', // 章节名
					href: ''  // 链接
				},{
					chapter: '', // 章节名
					href: ''  // 链接
				}]
			},{
				title: '', // 书名
				href: '',  // 链接
				latelyCatalogue: [{ // 最近看的章节
					chapter: '', // 章节名
					href: ''  // 链接
				},{
					chapter: '', // 章节名
					href: ''  // 链接
				},{
					chapter: '', // 章节名
					href: ''  // 链接
				}]
			}],
			latelySearch: ['', '', '', '', '', ''] //最近查询（允许存放5个结果）
		}
	},
	methods: {
		addLatelyType: function (index) {
			var type = this.localData.latelyType;
			for(var i = 0; i < type.length; i++){
				if(type[i].id === this.list[index].id){
					break;
				}else if(!type[i].id){
					type[i] = this.list[index];
					break;
				}
			}
			if(i === type.length){
				type.shift();
				type.push(this.list[index])
			}
			try{
				localStorage.setItem('lately', JSON.stringify(this.localData));
			}catch (err){
				console.log(err);
			}
        }
	},
	mounted: function () {
		try {
			var data = localStorage.getItem('lately');
			if(data){
				this.localData = JSON.parse(data);
			}else{
				localStorage.setItem('lately', JSON.stringify(this.localData));
			}
		} catch (err) {
			console.log(err);
		}
    }
});